/*
 * Created on 2005-7-15
 *
 */
package bma.common.langutil.bean.impl;

import java.util.LinkedList;
import java.util.List;

import bma.common.langutil.bean.BeanObject;
import bma.common.langutil.bean.BeanObjectProperty;
import bma.common.langutil.bean.BeanType;

/**
 * Bean - Object
 * 
 * @author guanzhong
 * @since 1.0 (imported from BMA.ESP Project)
 */
public class BeanObjectSimple implements BeanObject {

	private Class prototype;
	private List<BeanObjectProperty> properties = new LinkedList<BeanObjectProperty>();

	/**
	     * 
	     */
	public BeanObjectSimple() {
		super();
	}

	/**
	 * @param prototype
	 */
	public BeanObjectSimple(Class prototype) {
		super();
		this.prototype = prototype;
	}

	@Override
	public Class getPrototype() {
		return prototype;
	}

	@Override
	public BeanType getType() {
		return BeanType.OBJECT;
	}

	public void setPrototype(Class prototype) {
		this.prototype = prototype;
	}

	/**
	 * 获取属性
	 * 
	 * @param name
	 * @return
	 */
	@Override
	public BeanObjectProperty getDeclaredProperty(String name) {
		for (BeanObjectProperty prop : properties) {
			if (prop.getName().equals(name)) {
				return prop;
			}
		}
		return null;
	}

	/**
	 * 获取全部属性
	 * 
	 * @return
	 */
	@Override
	public List<BeanObjectProperty> getProperties() {
		return properties;
	}

	public void setProperties(List<BeanObjectProperty> properties) {
		this.properties = properties;
	}

	public void clear() {
		properties.clear();
	}
}
